package com.example.entity;

public abstract class Task {
    private Logger logger;

    private ReadMeConfig readMeConfig;

    private String packagePath;

    /**
     * 执行任务
     *
     * @return
     * @throws Exception
     */
    public abstract void execute() throws Exception;

    /**
     * 记录日志， 输出到前台
     *
     * @param message
     */
    protected final void log(String message) {
        if (this.logger != null) {
            logger.info(message);
        }
    }

    public final void setLogger(Logger logger) {
        this.logger = logger;
    }

    public final void setReadMeConfig(ReadMeConfig readMeConfig) {
        this.readMeConfig = readMeConfig;
    }

    public ReadMeConfig getReadMeConfig() {
        return readMeConfig;
    }

    public interface Logger {
        /**
         * 输出日志
         *
         * @param message
         */
        void info(String message);
    }
}
